package com.gnkexy.springframework.core.io;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;

public class FileSystemResource implements Resource {

    private String path;

    private File file;


    public FileSystemResource(String path) {
        this.path = path;
        this.file = new File(path);
    }
    public FileSystemResource(File file) {
        this.path = file.getPath();
        this.file = file;
    }

    @Override
    public InputStream getInputSteam() {

        FileInputStream fis = null;
        try {
            fis = new FileInputStream(this.file);
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        }

        return fis;
    }

    public final String getPath(){
        return this.path;
    }
}
